﻿{% extends "gma/base.html" %}
{% load static %}
{% load mytag %}

<!-- CSS
  =====================================================================-->

{% block extra_css %}
    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/inspinia.css' %}" rel="stylesheet">
    <link href="{% static 'css/inspinia_custom.css' %}" rel="stylesheet">
    <link href="{% static 'css/weui_custom.css' %}" rel="stylesheet">
{% endblock extra_css %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__bd">
    {#  ============================== 新版本的今日摘要 ============================== #}

    <div class="widget no-padding">
        <div class="p-xs">
            <div class="row vertical-align">
                <div class="col-8">
                    <h1 class="gma-title"> YYZB GMA{{ env.name }}</h1>
                </div>
                <div class="col-4 text-right">
                    <h1 class="gma-title">
                        {#退出按钮#}
                        <a href="javascript:logout()">
                            <i class="fa fa-sign-out-alt brief-icon-color"></i>
                        </a>

                        {#客服账号管理#}
                        {% if permissions.customer_service.open %}
                            <a v-if="brief.unread_customer_service_message_count > 0" v-cloak href="{% url 'gma:private_message_list' 120001 %}">
                                <i class="far fa-comment-dots red_color"></i>
                                <span class="weui-badge" style="position: absolute;top: 15px;right: 45px;">[[ brief.unread_customer_service_message_count ]]</span>
                            </a>
                            <a v-else href="{% url 'gma:private_message_list' 120001 %}">
                                <i class="far fa-comment-dots brief-icon-color"></i>
                            </a>
                        {% endif %}

                        {#用户投诉管理#}
                        {% if permissions.complaint_management.open %}
                            <a v-if="brief.opened_complaint_count > 0" v-cloak href="{% url 'gma:complaint' %}">
                                <i class="far fa-envelope m-l-sm red_color"></i>
                                <span class="weui-badge" style="position: absolute;top: 15px;right: 5px;">[[ brief.opened_complaint_count ]]</span>
                            </a>
                            <a v-else href="{% url 'gma:complaint' %}">
                                <i class="far fa-envelope m-l-sm brief-icon-color"></i>
                            </a>
                        {% endif %}
                    </h1>
                </div>
            </div>
        </div>
    </div>

    <div class="widget no-padding {{ env.bg }}">
        <div class="p-m" v-cloak>
            <div class="row vertical-align">
                <div class="col-10">
                    <p class="brief-header">
                        今日新增
                        {% if permissions.homepage_report.open %}
                            <span class="my-link"><a href="{% url 'gma:new_user_chart_detail' %}"><strong>[[ brief.today_new_user_count ]]</strong></a></span>
                        {% else %}
                            <strong> **** </strong>
                        {% endif %}
                        人，消耗
                        {% if permissions.homepage_report.open %}
                            <span class="my-link"><strong> [[ brief.today_consume_amount ]] </strong></span>
                        {% else %}
                            <strong> **** </strong>
                        {% endif %}
                        钻，累计充值
                    </p>
                </div>

{#                <div class="col-2 text-right">#}
{#                    {% if permissions.gm_management.open %}#}
{#                        <h2 class="font-bold"> <span class="my-link"><a href="{% url 'gma:gm_qrcode' gm_name %}"><i class="fa fa-qrcode"></i></a> </span></h2>#}
{#                    {% else %}#}
{#                        <h2 class="font-bold"> <span class="my-link"><a href="javascript:alert('权限不足!');"><i class="fa fa-qrcode"></i></a> </span></h2>#}
{#                    {% endif %}#}
{#                </div>#}
            </div>

            <p class="m-xs">
                <span class="f-xl">￥</span>
                <span class="f-xxl">
                    {% if permissions.homepage_report.open %}
                        [[ brief.today_pay_amount ]]
                    {% else %}
                        <strong> **** </strong>
                    {% endif %}
                </span>
                {% if permissions.homepage_report.open %}
                <span class="f-m light_white_color">ARPU [[ brief.arpu ]]</span>
                {% endif %}
            </p>

            <div class="brief-footer">
                <span class="my-link f-m">
                {% if permissions.homepage_report.open %}
                    <a href="{% url 'gma:pay_chart_detail' %}"><i class="fa fa-file-invoice-dollar"></i> <strong>收款记录</strong></a>
                {% else %}
                    <a href=""><i class="fa fa-file-invoice-dollar"></i> <strong>收款记录</strong></a>
                {% endif %}
                </span> |
                <span class="my-link f-m">
                {% if permissions.homepage_report.open %}
                    <a href="{% url 'gma:consume_detail' begin_time end_time %}"><i class="fa fa-gem"></i> <strong>消费记录 </strong></a>
                {% else %}
                    <a href=""><i class="fa fa-gem"></i> <strong>消费记录 </strong></a>
                {% endif %}
                </span>
{#                |#}
{#                <span class="my-link f-m">#}
{#                {% if permissions.homepage_report.open %}#}
{#                    <a href="{% url 'gma:call_count_chart_detail' %}"><i class="fa fa-clock"></i> <strong>通话记录 </strong></a>#}
{#                {% else %}#}
{#                    <a href=""><i class="fa fa-clock"></i> <strong>通话记录 </strong></a>#}
{#                {% endif %}#}
{#                </span>#}
            </div>
        </div>
    </div>

    {#  ============================== 数据监测 ============================== #}

{#    {% if diamond_detail.diamond_delta != 0 %}#}
{#        {% if permissions.system_config.open %}#}
{#            <div class="weui-panel weui-panel_access">#}
{#                <div class="weui-panel__hd">数据监测</div>#}
{#                <div class="weui-panel__bd">#}
{#                    <a class="weui-cell weui-cell_access" href="{% url 'gma:diamond_detail' %}">#}
{#                        <div class="weui-cell__bd"> <p> <i class="fa fa-gem gm_menu_item_icon"></i> 钻石误差 </p> </div>#}
{#                        {% if diamond_detail.diamond_delta == 0 %}#}
{#                        <div class="weui-cell__ft"> {{ diamond_detail.diamond_delta }} <i class="fa fa-gem"></i> </div>#}
{#                        {% else %}#}
{#                        <div class="weui-cell__ft" style="color:red"> {{ diamond_detail.diamond_delta }} <i class="fa fa-gem"></i> </div>#}
{#                        {% endif %}#}
{#                    </a>#}
{#                </div>#}
{#            </div>#}
{#        {% endif %}#}
{#    {% endif %}#}

{#    {% if permissions.system_config.open %}#}
{#        <div class="weui-panel weui-panel_access">#}
{#            <div class="weui-panel__hd">服务器监测</div>#}
{#            <div class="weui-panel__bd">#}
{#                <a class="weui-cell weui-cell_access" href="{% url 'gma:diamond_detail' %}">#}
{#                    <div class="weui-cell__bd"> <p> 在线人数 </p> </div>#}
{#                    <div class="weui-cell__ft"> [[ online_user_count ]] <i class="fa fa-user"></i> </div>#}
{#                </a>#}
{#            </div>#}
{#        </div>#}
{#    {% endif %}#}

    {#  ============================== 功能模块 ============================== #}

    <div class="weui-grids">
        <a href="{% url 'gma:entry_search' %}" class="weui-grid">
            <div class="weui-grid__icon">
                <i class="fa fa-search"></i>
            </div>
            <p class="weui-grid__label"> 用户定位 </p>
        </a>

    {% if permissions.broadcaster_management.open %}
        <a href="{% url 'gma:entry_auth' %}" class="weui-grid">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid">
    {% endif %}
            <div class="weui-grid__icon"> <i class="fa fa-eye"> </i> </div>
            <p class="weui-grid__label"> 内容审核
                <span v-if="brief.waiting_auth_count > 0" class="weui-badge weui-badge_dot" style="margin-left: 5px;margin-right: 5px;"></span>
            </p>
        </a>

    {% if permissions.app_management.open %}
        <a href="{% url 'gma:entry_app' %}" class="weui-grid-right">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid-right">
    {% endif %}
            <div class="weui-grid__icon"> <i class="fab fa-app-store-ios"></i> </div>
            <p class="weui-grid__label"> APP配置 </p>
        </a>

{#    {% if permissions.agent_management.open %}#}
{#        <a href="{% url 'gma:entry_promote' %}" class="weui-grid-right">#}
{#    {% else %}#}
{#        <a href="javascript:alert('权限不足!');" class="weui-grid-right">#}
{#    {% endif %}#}
{#            <div class="weui-grid__icon"> <i class="fa fa-podcast"></i> </div>#}
{#            <p class="weui-grid__label"> 推广管理#}
{#                <span v-if="brief.waiting_auth_withdraw_count > 0" class="weui-badge weui-badge_dot" style="margin-left: 5px;margin-right: 5px;"></span>#}
{#            </p>#}
{#        </a>#}

    {% if permissions.guild_management.open %}
        <a href="{% url 'gma:guild' %}" class="weui-grid">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid">
    {% endif %}
            <div class="weui-grid__icon">
                <i class="fa fa-landmark"></i>
            </div>
            <p class="weui-grid__label"> 公会管理 </p>
        </a>

    {% if permissions.market_management.open %}
        <a href="{% url 'gma:entry_market' %}" class="weui-grid">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid">
    {% endif %}
            <div class="weui-grid__icon"> <i class="fa fa-toolbox"></i> </div>
            <p class="weui-grid__label"> 运营工具 </p>
        </a>


    {% if permissions.security.open %}
        <a href="{% url 'gma:entry_security' %}" class="weui-grid-right">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid-right">
    {% endif %}
            <div class="weui-grid__icon">
                <i class="fa fa-shield-alt"></i>
            </div>
            <p class="weui-grid__label"> 安全管理 </p>
        </a>

        <a href="{% url 'gma:entry_service' %}" class="weui-grid-bottom">
            <div class="weui-grid__icon"> <i class="fa fa-plug"></i> </div>
            <p class="weui-grid__label"> 外部工具 </p>
        </a>

        <a href="{% url 'gma:entry_download' %}" class="weui-grid-bottom">
            <div class="weui-grid__icon">
                <i class="fa fa-cloud-download-alt"></i>
            </div>
            <p class="weui-grid__label"> 产品下载 </p>
        </a>

    {% if permissions.system_config.open %}
        <a href="{% url 'gma:entry_system' %}" class="weui-grid-right-bottom">
    {% else %}
        <a href="javascript:alert('权限不足!');" class="weui-grid-right-bottom">
    {% endif %}
            <div class="weui-grid__icon">
                <i class="fa fa-cogs"></i>
            </div>
            <p class="weui-grid__label"> 系统设置 </p>
        </a>
    </div>
</div>

<div class="page__ft">
    <span class="bottom-logo">
        HiBao
   </span>
</div>

{% endblock content %}

<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script>

new Vue({
    el: '#app',
    delimiters:['[[', ']]'],

    data: {
        // 在线人数
        online_user_count: 0,

        // 服务器摘要
        brief: {
            unread_customer_service_message_count: 0,
            opened_complaint_count: 0,
            today_new_user_count: '***',
            today_consume_amount: '***',
            today_pay_amount: '***',
            arpu: '***',
            waiting_auth_count: 0,
            waiting_auth_withdraw_count: 0,
        },
    },

    methods: {
        requestBriefData() {
            let url = "{% url 'gma:api_brief_data' %}";
            let data = { };
            new my_ajax(url, data, '', '', (data) => {
                this.brief = data;
            });
        },

        requestOnlineUserCount() {
            let url = "{% url 'gma:api_get_online_user_count' %}";
            let data = { };
            new my_ajax(url, data, '', '', (data) => {
                this.online_user_count = data['online_user_count'];
            });
        },
    },

    mounted() {
        this.requestBriefData();
        this.requestOnlineUserCount();
    },
});

function logout() {
    show_confirm_dialog('退出登录', '你确定要退出登录吗?', ()=> {
        my_ajax('{% url 'gma:api_logout' %}', {}, '', '', () => {
            window.location.reload();
        });
    });
}

</script>

{% endblock extra_js %}